#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    //this
    void print() const
    {
        if(this != nullptr)
        {
            cout << "(" << this->_ix
                 << ", " << _iy
                 << ")" << endl;
        }
        else
        {
            cout << "this == nullptr" << endl;
        }
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
};

void test()
{
    Point *pt = new Point(1, 2);
    delete pt;
    pt = nullptr;

    int *parr = new int[10]();
    delete [] parr;
    parr = nullptr;

    /* Point *pArr = new Point[4](); */
    Point *pArr = new Point[4]{Point(1, 2), Point(3, 4)};
    pArr[0].print();
    pArr[1].print();
    pArr[2].print();
    pArr[3].print();

    /* free(pArr);//error */
    delete [] pArr;
    pArr = nullptr;
}


int main(int argc, char *argv[])
{
    test();
    return 0;
}

